home *** CD-ROM | disk | FTP | other *** search
- Path: io.UWinnipeg.ca!wsimpson
- From: Bill Simpson <wsimpson@uwinnipeg.ca>
- Newsgroups: comp.lang.c
- Subject: goto
- Date: Wed, 13 Mar 1996 10:35:13 -0600
- Organization: The University of Manitoba
- Message-ID: <Pine.OSF.3.91.960313102715.10701D-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: io.uwinnipeg.ca
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
- There was a goto thread lately, and my problem is to state this algorithm
- cleanly without gotos (which I think is easy, but my attempts have been
- failures).
-
- 0. x=0;
- 1. x+=erand(maxmean);
- 2. if (urand2()>rate(x)/maxrate)
- goto step 1
- 3. if (x<=XMAX)
- {
- setdot(x,y,z);
- goto step 1
- }
- explanation:
- erand(mean) returns exponential double random number with given mean
- urand2() returns uniform double random number between 0 & 1
- rate(). well the rate of the Poisson process varies with x
-
- Any help gratefully received.
-
- Bill Simpson
-